#!/bin/bash

killall xlunch

COMMAND=$(
     xlunch --input /etc/xlunch/logout.dsv --noprompt --border auto --sideborder auto --columns 3 --rows 1 \
            --backgroundcolor 00000066 \
            --background /usr/share/wallpapers/slax_wallpaper.jpg --font DejaVuSans/11 \
            --voidclickterminate --iconpadding 30 --textpadding 10 \
            --leastmargin 10 --hidemissing --iconsize 128 \
            --highlight /usr/share/icons/hicolor/128x128/apps/xlunch_highlight.png \
            --outputonly
)

SND=/usr/share/sounds/shutdown.wav

if [ "$COMMAND" != "" -a -r $SND ]; then
   # blank desktop with smooth effect (if compton still running)
   xlunch --noprompt --input /dev/null --bc 111111ff &
   # play shutdown sound
   aplay $SND
fi

if [ "$COMMAND" = "logout" ]; then
   killall Xorg
fi

if [ "$COMMAND" = "restart" ]; then
   reboot
fi

if [ "$COMMAND" = "shutdown" ]; then
   poweroff
fi
